-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Node] Utility methods for ObjectPathPair handling #14498
[Node] Utility methods for ObjectPathPair handling #14498
Conversation
This commit adds a templated overload to `SEqualReducer::operator()` that accepts a lambda function to update the path of the LHS and RHS of the comparison. ```c++ // Usage prior to this utility function if (equal.IsPathTracingEnabled()) { const ObjectPathPair& self_paths = equal.GetCurrentObjectPaths(); ObjectPathPair attr_paths = {self_paths->lhs_path->Attr("value"), self_paths->rhs_path->Attr("value")}; if (!equal(this->value, other->value, attr_paths)) return false; } else { if (!equal(this->value, other->value)) return false; } // Usage after this utility function if (!equal(this->value, other->value, [](const auto& path) { return path->Attr("value"); })) { return false; } ```
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
This arose during debugging for #14486, but wasn't strictly necessary for it. |
if (!equal.DefEqual(gtv, other->GetGlobalTypeVar(gtv->name_hint))) return false; | ||
// Checking functions and type definitions | ||
if (!equal(this->functions, other->functions, | ||
[](const auto& path) { return path->Attr("functions"); })) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is func_path
(adding function name to the path) handled like before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, yes. The IRModule
's handler only needs to handle appending .functions
to the path, with the function name added by the equality check on Map
. This results in a path of <root>.functions[I.GlobalVar("func")].body...
.
I've added a unit test that verifies that the error message includes the function name, as that's definitely a good thing to verify for user-friendliness.
@tvm-bot rerun |
This commit adds a templated overload to
SEqualReducer::operator()
that accepts a lambda function to update the path of the LHS and RHS of the comparison.